{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    " %matplotlib inline\n",
    " import matplotlib.pyplot as plt\n",
    " import seaborn as sns\n",
    " import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [],
   "source": [
    "def make_data(N,f=0.3, rseed=1):\n",
    "    rng = np.random.default_rng(rseed)\n",
    "    x = rng.standard_normal(N)\n",
    "    x[int(f*N):]+=5\n",
    "    return x\n",
    "    \n",
    "x = make_data(1000)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "hist = plt.hist(x, bins=30, density=True, stacked=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "density, bins, patches = hist\n",
    "widths = bins[1:] - bins[:-1]\n",
    "(density * widths).sum()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [],
   "source": [
    "x = make_data(50)\n",
    "bins = np.linspace(-5, 10, 10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAskAAAD8CAYAAACFHTnaAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAAsTAAALEwEAmpwYAAAUd0lEQVR4nO3df6zdZ30f8Pdn9hLWIGgK3h+1E+y17qhXOtLdmm5o/DECmKWK+weoBjGFDSliIxsbnSZTpiRKVSkt08qkZRtRyVSttC4N3WQtpmla6KSpCrXDzzmZi2uyxB4TLmG0GozU8Nkf96Q7PLrJPff6Xp9zb14v6crn+3yf5/rz+Fx/9Nb3nu851d0BAAD+vz837wIAAGDRCMkAADAQkgEAYCAkAwDAQEgGAICBkAwAAI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obcuGL114SxMb53bleTniX+d5OokD02u3Dzc3e+cb0mz6e5LVXVbkgezfGfpfd19es5lrderk/ydJJ+vqs9Mxn66u0/Mr6TnvX+Y5MOTkHAuyd+dcz1r1t2frKr7k3wqy7/y/3S2z0fBLjq9dTHorYtHb91APpYaAAAGC/dyCwAAmDchGQAABkIyAAAMhGQAABgIyQAAMBCSAQBgICQDAMDg/wFPQio2Jq1EyQAAAABJRU5ErkJggg==",
      "text/plain": [
       "<Figure size 864x288 with 2 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig, ax = plt.subplots(1, 2, figsize=(12, 4), sharex=True, sharey=True, subplot_kw={'xlim':(-4, 9), 'ylim':(-0.02, 0.3)})\n",
    "fig.subplots_adjust(wspace=0.05)\n",
    "for i, offset in enumerate([0.0, 0.6]):\n",
    "    ax[i].hist(x, bins=bins + offset, density=True, stacked=True)\n",
    "    ax[i].plot(x, np.full_like(x, -0.01), '|k', markeredgewidth=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(-0.2, 8.0)"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAW0AAAD8CAYAAAC8TPVwAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAAsTAAALEwEAmpwYAAAOMklEQVR4nO3df4hl9X3G8efprlbdbGKot6FxHRXarIhpor1YE4tLXQ2aiP4jdIUISVuGQn6oCCGm0KV/N8QEUgKLJi1oDc2qUEJi3RJDCdRtZ1eNP1bFmlR3NXGkWI39YU2f/jF3zGTm3nvO7N5z737G9wsG5575nnOeu+fO45lzzr3HSQQAqOFXZh0AANAepQ0AhVDaAFAIpQ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uSsJGdp6R/8gkqF3cT2FVr6U/TqJP856zwTsqFvduGlPYjbJR1K8qVZ55mkJLck2Tb4fdsl6XsbqLA16I7nbW8fTNop6YkZRpq05yRdZPuUwet0p8acaO3qU/42uq9K+lVJ+wZ/TTyY5E9mG+nYvA1udnGxlm5K/ajthwfTvjD4rHgc/z4j6c7BDsWzkj454zwTk2S/7b2SDmrpcOtDGvOWdt7GDgCF8I5IACiE0gaAQihtACiE0gaAQihtACiE0gaAQihtACjk/wGb6t3IX570QwAAAABJRU5ErkJggg==",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig, ax = plt.subplots()\n",
    "bins = np.arange(-3, 8)\n",
    "ax.plot(x, np.full_like(x, -0.1), '|k',markeredgewidth=1)\n",
    "for count, edge in zip(*np.histogram(x, bins)):\n",
    "    for i in range(count):\n",
    "        ax.add_patch(plt.Rectangle((edge, i), 1, 1,alpha=0.5))\n",
    "ax.set_xlim(-4, 8)\n",
    "ax.set_ylim(-0.2, 8)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAW0AAAD8CAYAAAC8TPVwAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAAsTAAALEwEAmpwYAAAbrklEQVR4nO3de4xcV30H8O9vd+04fiRO4k2a2Nk4bajTNJDEGYVA2qgQoAHSICqqmgokKGhVlUdASLwqFfXPqoiC1BTVCgGkhKBiErWKgCYIIwptXLyOQxI7gRBnYzshXhM/1mvv7jx+/WNm1jvvOzP3nHvO/X0/kmXP+M7c3z33nN89c859iKqCiIjiMJJ1AERElByTNhFRRJi0iYgiwqRNRBQRJm0ioogwaRMRRSRR0haRT4rI0y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DwBFVnco6FkfGAGwF8FVVvQHAHIDczLmIyAWo/qq9EtX7m6wRkfd1Wn7ge4+o6ls6BPDa2sqfqD3VYhOAPSJyk6r+ZtD1+dZp++pE5AMA7gBwm+bjZPfcP+xCRFagmrDvV9UHs44nRbcAuFNE3gFgFYDzROQ+Ve3Y8CNzCMAhVa3/MtqBHCVtAG8BcEBVZwBARB4E8EYA97VbOPXhEVV9UlUvVtXNqroZ1QLfGlPC7kVEbkf1p+idqno663hSkuuHXUi1B/E1APtV9UtZx5MmVf2cqm6qtbdtAH6Uo4SNWu44KCJbam/dBmBfhiGl7UUAN4vI6lo9vQ1dJlpd3eUv7/4FwDkAHq39mnhMVf8m25CGY+BhF7cAeD+AJ0Vkb+29z9fuFU/h+xiA+2sdiucBfDDjeFKjqrtEZAeAPagOtz6OLpe08zJ2IqKI8IpIIqKIMGkTEUWESZuIKCJM2kREEWHSJiKKCJM2EVFEmLSJiCLy/1K/UpSZowURAAAAAElFTkSuQmCC",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "x_d = np.linspace(-4, 8, 2000)\n",
    "density = sum((abs(xi - x_d) < 0.5) for xi in x)\n",
    "plt.fill_between(x_d, density, alpha=0.5)\n",
    "plt.plot(x, np.full_like(x, -0.1), '|k', markeredgewidth=1)\n",
    "plt.axis([-4, 8, -0.2, 8]);"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 76,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x264b39a8520>]"
      ]
     },
     "execution_count": 76,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXAAAAD4CAYAAAD1jb0+AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9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8jsf19EVVz4nIiwAuot1VegkuTqvnVHoiIkMZ04VCREQ3Y4ATERmKAU5EZCgGOBGRoRjgRESGYoATERmKAU5EZKh/B75eLrXKZLn3AAAAAElFTkSuQmCC",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "from scipy.stats import norm\n",
    "x_d = np.linspace(-4,8,1000)\n",
    "density = sum(norm(xi).pdf(x_d) for xi in x)\n",
    "plt.fill_between(x_d, density, alpha=0.5)\n",
    "plt.plot(x, np.full_like(x, -0.1), '|k', markeredgewidth=1)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 81,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(-0.02, 0.22)"
      ]
     },
     "execution_count": 81,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAD4CAYAAADiry33AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAAsTAAALEwEAmpwYAAAe2klEQVR4nO3de4yld33f8ffXu/ECtjGOvZSwvqxpDKkhNJDBpEHClgDHaSO7fxDhVKmgRbIixU3aJKogibDl9A9SqhakWC0WOKQJqQGX0I1ZsNfYa3xbe++7ntmd3blfdm7nzO3MmXN/vv1jzprZ2bmcmTnnPLfPS7I85znP88z32Zn5zDO/53cxd0dERJLrirALEBGR1lLQi4gknIJeRCThFPQiIgmnoBcRSbidYRew0g033OB79+4NuwwRkVg5evRoxt13r/Ze5IJ+7969HDlyJOwyRERixcwG13pPTTciIgmnoBcRSTgFvYhIwinoRUQSTkEvIpJwCnoRkYRT0IuIJFzk+tGLSDwFgTM6WyCzUMLMeOc1u/iFa9+CmYVdWuop6EVk285P5HjxfIa5QuWS7ddffSV3vnc3t1x/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uNfM/iXwFuDtZvZ37t60UGmjEWDE3S/+dfUkMQ164JNAv7tPAZjZ94FfB/6uGSeP5R39Wtz9tLu/0933uvtelr4RPhzVkN+Imd3D0p/Y97r7Ytj1bMFh4DYzu9XMrmTp4dK+kGvaNFu6a/gmcMbd/3vY9WyHu3/R3W+s/3zcDzwX05Cn/nM9bGbvq2/6BNAVYknbMQT8mpm9rf799gma+GA5lnf0KfJXwC7gQP0vlEPu/nvhltQ4d6+a2YPA0yz1Injc3TtDLmsrPgb8W+C0mZ2ob/tTd98fXklS9x+Ab9dvJPqAfxdyPVvi7q+Z2ZPAMZaaaY/TxOkQNAWCiEjCJarpRkRELqegFxFJOAW9iEjCKehFRBJOQS8iknAKehGRhFPQi4gk3P8H4vDjGOYRoX4AAAAASUVORK5CYII=",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "from sklearn.neighbors import KernelDensity\n",
    "kde = KernelDensity(bandwidth=1.0, kernel='gaussian')\n",
    "kde.fit(x[:,None])\n",
    "logprob = kde.score_samples(x_d[:,None])\n",
    "\n",
    "plt.fill_between(x_d, np.exp(logprob), alpha=0.5)\n",
    "plt.plot(x,np.full_like(x,-0.01), '|k', markeredgewidth=1)\n",
    "plt.ylim(-0.02, 0.22)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 78,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "50"
      ]
     },
     "execution_count": 78,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "metadata": {},
   "outputs": [],
   "source": [
    "t = np.arange(2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[array([ 4.      ,  3.993997,  3.987994, ..., -7.987994, -7.993997,\n",
       "        -8.      ]),\n",
       " array([ 5.      ,  4.993997,  4.987994, ..., -6.987994, -6.993997,\n",
       "        -7.      ])]"
      ]
     },
     "execution_count": 74,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "[v - x_d for v in t]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0, 1])"
      ]
     },
     "execution_count": 71,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "t"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "interpreter": {
   "hash": "e21935a792cabaadabb39e077efde3aadff814271e124eae6fb74a8aae0f5081"
  },
  "kernelspec": {
   "display_name": "Python 3.10.5 64-bit",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.5"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
